package com.hll.javaweb.servlet.reflect_servlet;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author hll
 * @create 2022-05-10 16:07
 */
@WebServlet("/reflect")
public class ServletTest extends BaseServlet { // 不再需要继承HttpServlet了
  // 请求为 reflect?action=walk
  // 注意不能写成 private , 反射的时候没有设置私有方法的访问权..建议也不要设置，防止越权访问
  // 尽量写成public，否则protected 不同包时没权限！！
  public void walk(HttpServletRequest request, HttpServletResponse response) throws IOException {
    response.getWriter().write("walk");
  }
  // reflect?action=talk
  public void talk(HttpServletRequest request, HttpServletResponse response) throws IOException {
    response.getWriter().write("talk");
  }
}
